//
//  ViewController.swift
//  View
//
//  Created by lanou on 16/11/4.
//  Copyright (c) 2016年 lanou. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
       let rootbtn = UIButton(frame: CGRectMake(100, 100, 50, 50))
        rootbtn.setTitle("next", forState: .Normal)
        rootbtn.backgroundColor = UIColor.blueColor()
        rootbtn.addTarget(self, action: "nextPage",forControlEvents: .TouchUpInside)
        view.addSubview(rootbtn)
        view.backgroundColor = UIColor.redColor()
        let label = UILabel(frame: CGRectMake(50, 110, 80, 30))
        label.text = "pageOne"
        
    }
    func nextPage(){
    let view2 = SecondViewController()
        view2.closure = {
            (color:UIColor)->Void
            in
            self.view.backgroundColor = color
        }
        navigationController?.pushViewController(view2, animated: true)
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

